<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>npm介绍及使用 | H5学习笔记</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        <meta name="author" content="逍遥派">
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    
    <link rel="prev" href="../../md/node.js/nvm.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="5.2"
        data-chapter-title="npm介绍及使用"
        data-filepath="md/node.js/npm.md"
        data-basepath="../.."
        data-revision="Thu Dec 14 2017 19:20:03 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="md/html/html.html">
            
                
                    <a href="../../md/html/html.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        HTML
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="md/html/know.html">
            
                
                    <a href="../../md/html/know.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        认识页面、以及行内元素和块级元素
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="md/html/a.html">
            
                
                    <a href="../../md/html/a.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.1.</b>
                        
                        a标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="md/html/path.html">
            
                
                    <a href="../../md/html/path.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.2.</b>
                        
                        文件路径
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.3" data-path="md/html/img.html">
            
                
                    <a href="../../md/html/img.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.3.</b>
                        
                        img标签
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.4" data-path="md/html/area.html">
            
                
                    <a href="../../md/html/area.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.4.</b>
                        
                        锚点和热区
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.5" data-path="md/html/table.html">
            
                
                    <a href="../../md/html/table.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.5.</b>
                        
                        表格
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.6" data-path="md/html/media.html">
            
                
                    <a href="../../md/html/media.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.6.</b>
                        
                        音频与视频
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.7" data-path="md/html/list.html">
            
                
                    <a href="../../md/html/list.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.7.</b>
                        
                        列表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.8" data-path="md/html/jframe.html">
            
                
                    <a href="../../md/html/jframe.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.8.</b>
                        
                        内嵌页面
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.9" data-path="md/html/icon.html">
            
                
                    <a href="../../md/html/icon.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.9.</b>
                        
                        网页icon
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.10" data-path="md/html/character.html">
            
                
                    <a href="../../md/html/character.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.10.</b>
                        
                        实体字符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.11" data-path="md/html/form.html">
            
                
                    <a href="../../md/html/form.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.11.</b>
                        
                        form表单
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.12" data-path="md/html/input.html">
            
                
                    <a href="../../md/html/input.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.12.</b>
                        
                        input标签
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.12.1" data-path="md/html/input/radio.html">
            
                
                    <a href="../../md/html/input/radio.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.12.1.</b>
                        
                        radio
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.12.2" data-path="md/html/input/checkbox.html">
            
                
                    <a href="../../md/html/input/checkbox.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.12.2.</b>
                        
                        checkbox
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.12.3" data-path="md/html/input/select.html">
            
                
                    <a href="../../md/html/input/select.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.12.3.</b>
                        
                        select
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.12.4" data-path="md/html/input/file.html">
            
                
                    <a href="../../md/html/input/file.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.12.4.</b>
                        
                        file
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.12.5" data-path="md/html/input/textarea.html">
            
                
                    <a href="../../md/html/input/textarea.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.12.5.</b>
                        
                        textarea
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.1.12.6" data-path="md/html/input/button.html">
            
                
                    <a href="../../md/html/input/button.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.12.6.</b>
                        
                        button
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="md/css/css.html">
            
                
                    <a href="../../md/css/css.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        CSS
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="md/css/selector.html">
            
                
                    <a href="../../md/css/selector.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        CSS选择器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="md/css/selector/element.html">
            
                
                    <a href="../../md/css/selector/element.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.1.</b>
                        
                        元素选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="md/css/selector/class.html">
            
                
                    <a href="../../md/css/selector/class.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.2.</b>
                        
                        类选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="md/css/selector/id.html">
            
                
                    <a href="../../md/css/selector/id.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.3.</b>
                        
                        ID选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="md/css/selector/descendant.html">
            
                
                    <a href="../../md/css/selector/descendant.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.4.</b>
                        
                        后代选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.5" data-path="md/css/selector/child.html">
            
                
                    <a href="../../md/css/selector/child.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.5.</b>
                        
                        子元素选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.6" data-path="md/css/selector/general.html">
            
                
                    <a href="../../md/css/selector/general.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.6.</b>
                        
                        兄弟选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.7" data-path="md/css/selector/adjacent.html">
            
                
                    <a href="../../md/css/selector/adjacent.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.7.</b>
                        
                        相邻选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.8" data-path="md/css/selector/pseudo.html">
            
                
                    <a href="../../md/css/selector/pseudo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.8.</b>
                        
                        伪类选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.9" data-path="md/css/selector/att.html">
            
                
                    <a href="../../md/css/selector/att.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.9.</b>
                        
                        属性选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.1.10" data-path="md/css/selector/object.html">
            
                
                    <a href="../../md/css/selector/object.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.10.</b>
                        
                        伪对象选择符
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="md/css/style.html">
            
                
                    <a href="../../md/css/style.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        CSS样式属性
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="md/css/style/font.html">
            
                
                    <a href="../../md/css/style/font.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.1.</b>
                        
                        font属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="md/css/style/color.html">
            
                
                    <a href="../../md/css/style/color.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.2.</b>
                        
                        color属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="md/css/style/text-decoration.html">
            
                
                    <a href="../../md/css/style/text-decoration.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.3.</b>
                        
                        text-decoration属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="md/css/style/text-shadow.html">
            
                
                    <a href="../../md/css/style/text-shadow.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.4.</b>
                        
                        text-shadow属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="md/css/style/box.html">
            
                
                    <a href="../../md/css/style/box.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.5.</b>
                        
                        box盒子模型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2.6" data-path="md/css/style/align.html">
            
                
                    <a href="../../md/css/style/align.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.6.</b>
                        
                        对齐属性
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="md/gitbook/introduce.html">
            
                
                    <a href="../../md/gitbook/introduce.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        gitbook
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="md/gitbook/us e.html">
            
            <span><b>3.1.</b> gitbook安装及使用</span>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="md/gitbook/mardown.html">
            
                
                    <a href="../../md/gitbook/mardown.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        Markdown编辑器语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="md/gitbook/plugins.html">
            
                
                    <a href="../../md/gitbook/plugins.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        Markdown插件安装配置
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="md/git/git.html">
            
                
                    <a href="../../md/git/git.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        git介绍
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="md/git/use.html">
            
                
                    <a href="../../md/git/use.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        git安装使用
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="md/node.js/introduce.html">
            
                
                    <a href="../../md/node.js/introduce.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        NodeJs
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="md/node.js/nvm.html">
            
                
                    <a href="../../md/node.js/nvm.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        nvm管理nodejs
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="5.2" data-path="md/node.js/npm.html">
            
                
                    <a href="../../md/node.js/npm.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        npm介绍及使用
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >H5学习笔记</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="npm&#x7684;&#x4F7F;&#x7528;">npm&#x7684;&#x4F7F;&#x7528;</h1>
<h2 id="&#x51E0;&#x4E2A;npm&#x7684;&#x5E38;&#x7528;&#x547D;&#x4EE4;">&#x51E0;&#x4E2A;npm&#x7684;&#x5E38;&#x7528;&#x547D;&#x4EE4;</h2>
<p><a href="http://html5book.bluej.cn/_book/md/14-nodejs/npm%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8.html" target="_blank">npm&#x5B98;&#x7F51;</a>   </p>
<p>&#x4E00;&#x4E2A;&#x4F9D;&#x8D56;&#x4E8E;nodejs&#x73AF;&#x5883;&#x7684;&#x5305;&#x7BA1;&#x7406;&#x5668;&#xFF0C;&#x53EA;&#x8981;&#x4F60;&#x662F;&#x4E00;&#x4E2A;&#x73B0;&#x4EE3;&#x524D;&#x7AEF;&#x4EBA;&#x5458;&#xFF0C;&#x4F60;&#x5C31;&#x5FC5;&#x987B;&#x638C;&#x63E1;&#x548C;&#x8BA4;&#x8BC6;&#x5B83;&#x3002;</p>
<pre><code>npm -v          #&#x663E;&#x793A;&#x7248;&#x672C;&#xFF0C;&#x68C0;&#x67E5;npm &#x662F;&#x5426;&#x6B63;&#x786E;&#x5B89;&#x88C5;&#x3002;
npm root -g     //&#x83B7;&#x53D6;&#x5F53;&#x524D;node_modeuls&#x5168;&#x5C40;&#x63D2;&#x4EF6;&#x7684;&#x5B89;&#x88C5;&#x4F4D;&#x7F6E;&#xFF0C;&#x5176;&#x5B9E;&#x5C31;&#x662F;prefix&#x53D8;&#x91CF;&#x540E;&#x9762;&#x8FFD;&#x52A0;node_modules
npm install express   #&#x5B89;&#x88C5;express&#x6A21;&#x5757;
npm install express@3.5.0   #&#x5B89;&#x88C5;&#x6307;&#x5B9A;&#x7248;&#x672C;&#x7684;express&#x6A21;&#x5757;
npm install -g express  #&#x5168;&#x5C40;&#x5B89;&#x88C5;express&#x6A21;&#x5757;
npm uninstall express (-g)  #&#x5220;&#x9664;&#x6307;&#x5B9A;&#x7684;&#x6A21;&#x5757;
npm update        #&#x5347;&#x7EA7;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x9879;&#x76EE;&#x7684;&#x6240;&#x6709;&#x6A21;&#x5757;
npm update webpack    #&#x5347;&#x7EA7;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x9879;&#x76EE;&#x7684;&#x6307;&#x5B9A;&#x6A21;&#x5757;
npm update webpack@latest    #&#x66F4;&#x65B0;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x7684;webpack&#x6A21;&#x5757;&#x5230;&#x6700;&#x65B0;&#x7248;
npm update webpack@2.5.0    #&#x66F4;&#x65B0;&#x6307;&#x5B9A;&#x7248;&#x672C;&#x7684;webpack&#x6A21;&#x5757;&#x5230;2.5.0&#x7248;&#x672C;
npm update -g express  #&#x5347;&#x7EA7;&#x5168;&#x5C40;&#x5B89;&#x88C5;&#x7684;express&#x6A21;&#x5757;
npm list      #&#x5217;&#x51FA;&#x5DF2;&#x5B89;&#x88C5;&#x6A21;&#x5757;&#xFF0C;&#x53EF;&#x4EE5;&#x7F29;&#x5199;&#x4E3A;npm ls,&#x5982;&#x9700;&#x67E5;&#x770B;&#x5168;&#x5C40;&#x5219;&#x52A0;-g&#x53C2;&#x6570;
npm list  --depth=0 -g   #&#x5217;&#x51FA;&#x5DF2;&#x5B89;&#x88C5;&#x7684;&#x5168;&#x5C40;&#x9AD8;&#x7EA7;&#x6A21;&#x5757;&#xFF0C;&#x8BE5;&#x547D;&#x4EE4;&#x5E38;&#x7528;&#x6765;&#x68C0;&#x67E5;&#x672C;&#x5730;&#x662F;&#x5426;&#x5B89;&#x88C5;&#x67D0;&#x4E2A;&#x5E94;&#x7528;&#x5E93;
npm config set prefix c:\123\   #&#x8BBE;&#x7F6E;&#x914D;&#x7F6E;&#xFF0C;&#x4F8B;&#x5982;&#x8BBE;&#x7F6E;&#x5168;&#x5C40;node_module&#x6240;&#x5728;&#x6587;&#x4EF6;&#x5939;
npm config get prefix           #&#x8BFB;&#x53D6;&#x914D;&#x7F6E;&#xFF0C;&#x4F8B;&#x5982;&#x8BFB;&#x53D6;&#x5168;&#x5C40;node_module&#x6240;&#x5728;&#x6587;&#x4EF6;&#x5939;


npm show express     #&#x663E;&#x793A;&#x6A21;&#x5757;&#x8BE6;&#x60C5;
npm cache clean &#x6E05;&#x7406;&#x7F13;&#x5B58;
npm help xxx  &#x67E5;&#x770B;&#x5E2E;&#x52A9;
npm view moudlename dependencies  &#x67E5;&#x770B;&#x5305;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;
npm view modulenames  &#x67E5;&#x770B;node&#x6A21;&#x5757;&#x7684;package.json&#x6587;&#x4EF6;&#x5939;
npm view modulename labelname  &#x67E5;&#x770B;package.json&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x67D0;&#x4E2A;&#x6807;&#x7B7E;&#x7684;&#x5185;&#x5BB9;
npm view modulename repository.url  &#x67E5;&#x770B;&#x5305;&#x7684;&#x6E90;&#x6587;&#x4EF6;&#x5730;&#x5740;
npm view modulename engines   &#x67E5;&#x770B;&#x5305;&#x6240;&#x4F9D;&#x8D56;&#x7684;node&#x7684;&#x7248;&#x672C;
npm help folders   &#x67E5;&#x770B;npm&#x4F7F;&#x7528;&#x7684;&#x6240;&#x6709;&#x6587;&#x4EF6;&#x5939;
npm rebuild modulename    &#x7528;&#x4E8E;&#x66F4;&#x6539;&#x5305;&#x5185;&#x5BB9;&#x540E;&#x8FDB;&#x884C;&#x91CD;&#x5EFA;
npm outdated   &#x68C0;&#x67E5;&#x5305;&#x662F;&#x5426;&#x5DF2;&#x7ECF;&#x8FC7;&#x65F6;&#xFF0C;&#x6B64;&#x547D;&#x4EE4;&#x4F1A;&#x5217;&#x51FA;&#x6240;&#x6709;&#x5DF2;&#x7ECF;&#x8FC7;&#x65F6;&#x7684;&#x5305;&#xFF0C;&#x53EF;&#x4EE5;&#x53CA;&#x65F6;&#x8FDB;&#x884C;&#x5305;&#x7684;&#x66F4;&#x65B0;

##&#x5173;&#x4E8E;&#x53D1;&#x5E03;&#x6A21;&#x5757;&#x7684;&#x51E0;&#x4E2A;&#x5E38;&#x7528;&#x547D;&#x4EE4;
npm adduser                 //&#x6CE8;&#x518C;https://www.npmjs.com &#x4E0A;&#x9762;&#x7684;&#x8D26;&#x53F7;
npm login                //&#x7528;&#x6CE8;&#x518C;&#x7684;&#x8D26;&#x6237;&#x767B;&#x5F55;&#xFF0C;&#x9700;&#x8981;&#x8F93;&#x5165;&#x8D26;&#x6237;&#x540D;&#xFF0C;&#x5BC6;&#x7801;&#x548C;&#x90AE;&#x7BB1;
npm owner ls &lt;package_name&gt; //&#x67E5;&#x770B;&#x6A21;&#x5757;&#x62E5;&#x6709;&#x8005; 
npm owner add &lt;user&gt; &lt;package_name&gt;  //&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x53D1;&#x5E03;&#x8005; 
npm owner rm &lt;user&gt; &lt;package_name&gt; //&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x53D1;&#x5E03;&#x8005; 
npm publish                 //&#x628A;&#x81EA;&#x5DF1;&#x7684;NPM&#x5305;&#x63A8;&#x9001;&#x5230;npmjs&#x5E02;&#x573A;&#x4E0A;
npm unpublish &#x5305;&#x540D; --force   //&#x5220;&#x9664;&#x5728;npmjs&#x5E02;&#x573A;&#x4E0A;&#x7684;&#x5305;&#xFF0C;&#x4F46;&#x6CE8;&#x610F;&#xFF0C;&#x73B0;&#x5728;&#x5B98;&#x65B9;&#x89C4;&#x5B9A;&#x53EA;&#x80FD;&#x5220;&#x9664;24&#x5C0F;&#x65F6;&#x5185;&#x53D1;&#x5E03;&#x7684;&#x5305;
npm search &lt;package_name&gt;   //&#x641C;&#x7D22;&#x5E02;&#x573A;&#x662F;&#x662F;&#x5426;&#x5B58;&#x5728;&#x67D0;&#x4E2A;&#x5305;&#x540D;
</code></pre><h2 id="savedev-&#x4E0E;-save&#x533A;&#x522B;">--save-dev &#x4E0E; --save&#x533A;&#x522B;</h2>
<p>1.--save-dev &#x662F;&#x4F60;&#x5F00;&#x53D1;&#x65F6;&#x5019;&#x4F9D;&#x8D56;&#x7684;&#x4E1C;&#x897F;
2.--save &#x662F;&#x4F60;&#x53D1;&#x5E03;&#x4E4B;&#x540E;&#x8FD8;&#x4F9D;&#x8D56;&#x7684;&#x4E1C;&#x897F;&#x3002;</p>
<pre><code>&#x6BD4;&#x5982;&#xFF0C;&#x4F60;&#x5199; ES6 &#x4EE3;&#x7801;&#xFF0C;&#x5982;&#x679C;&#x4F60;&#x60F3;&#x7F16;&#x8BD1;&#x6210; ES5 &#x53D1;&#x5E03;&#x90A3;&#x4E48; babel &#x5C31;&#x662F;devDependencies&#x3002; &#x5982;&#x679C;&#x4F60;&#x7528;&#x4E86; jQuery&#xFF0C;&#x7531;&#x4E8E;&#x53D1;&#x5E03;&#x4E4B;&#x540E;&#x8FD8;&#x662F;&#x4F9D;&#x8D56;jQuery&#xFF0C;&#x6240;&#x4EE5;&#x662F;dependencies&#x3002;
</code></pre><p>&#x53E6;&#x5916;&#x9700;&#x8981;&#x8865;&#x5145;&#x7684;&#x662F;&#xFF1A;</p>
<pre><code>&#x6B63;&#x5E38;&#x4F7F;&#x7528;npm install&#x65F6;&#xFF0C;&#x4F1A;&#x4E0B;&#x8F7D;dependencies&#x548C;devDependencies&#x4E2D;&#x7684;&#x6A21;&#x5757;&#xFF0C;
&#x5F53;&#x4F7F;&#x7528;npm install --production
&#x6216;&#x8005;&#x6CE8;&#x660E;NODE_ENV&#x53D8;&#x91CF;&#x503C;&#x4E3A;production&#x65F6;&#xFF0C;
&#x53EA;&#x4F1A;&#x4E0B;&#x8F7D;dependencies&#x4E2D;&#x7684;&#x6A21;&#x5757;&#x3002;
</code></pre><h2 id="&#x5173;&#x4E8E;&#x672C;&#x5730;&#x5B89;&#x88C5;&#x548C;&#x5168;&#x5C40;&#x5B89;&#x88C5;&#x540E;&#xFF0C;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;">&#x5173;&#x4E8E;&#x672C;&#x5730;&#x5B89;&#x88C5;&#x548C;&#x5168;&#x5C40;&#x5B89;&#x88C5;&#x540E;&#xFF0C;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x7684;&#x4F7F;&#x7528;</h2>
<p>&#x62FF;webpack&#x8FD9;&#x4E2A;&#x63D2;&#x4EF6;&#x6765;&#x8BF4;</p>
<pre><code>npm i -g webpack
</code></pre><p>&#x8FD9;&#x6837;&#x662F;&#x53EF;&#x4EE5;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x7684;(&#x56E0;&#x4E3A;&#x6DFB;&#x52A0;&#x4E86;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4E2D;&#x627E;&#x5230;&#x8BE5;&#x547D;&#x4EE4;)&#x3002;<br> &#x4F46;&#x5F0A;&#x7AEF;&#x5C31;&#x662F;&#x6240;&#x6709;&#x9879;&#x76EE;&#x7684;webpack&#x7248;&#x672C;&#x90FD;&#x4F9D;&#x8D56;&#x4E8E;&#x5168;&#x5C40;&#x7684;webpack&#x5F53;&#x524D;&#x7248;&#x672C;&#xFF0C;&#x65E0;&#x6CD5;&#x505A;&#x5230;&#x5DEE;&#x5F02;&#x5316;&#x3002;</p>
<h2 id="&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x5C40;&#x90E8;&#x5B89;&#x88C5;">&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x5C40;&#x90E8;&#x5B89;&#x88C5;</h2>
<pre><code>npm i webpack --save-dev
</code></pre><p>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4E0B;&#x9762;&#x4E24;&#x79CD;&#x5F62;&#x5F0F;&#x6765;&#x8C03;&#x7528;&#x5C40;&#x90E8;&#x547D;&#x4EE4;
1.&#x8865;&#x5168;&#x672C;&#x5730;&#x547D;&#x4EE4;&#x8DEF;&#x5F84;&#x6765;&#x8C03;&#x7528;</p>
<pre><code>./node_modules/.bin/webpack --help #linux&#x6216;mac&#x73AF;&#x5883;&#x4E0B;
.\node_modules\.bin\webpack --help #windows&#x73AF;&#x5883;&#x4E0B;
</code></pre><p>&#x56E0;&#x4E3A;&#x672C;&#x5730;&#x5B89;&#x88C5;&#x7684;&#x547D;&#x4EE4;&#xFF0C;&#x6CA1;&#x6709;&#x52A0;&#x5165;&#x5230;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x4E2D;&#xFF0C;&#x65E0;&#x6CD5;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#xFF0C;&#x9700;&#x8981;&#x8865;&#x5168;&#x8DEF;&#x5F84;</p>
<p>2.&#x76F4;&#x63A5;&#x5199;&#x5728;package.json&#x7684;script&#x811A;&#x672C;&#x91CC;</p>
<pre><code>//package.json
&quot;scripts&quot;: {
&quot;webpack-v&quot;:&quot;webpack -version&quot;
},
</code></pre><p>&#x547D;&#x4EE4;&#x884C;&#x8C03;&#x7528;</p>
<pre><code> npm run webpack-v
</code></pre><p>&#x8FD9;&#x91CC;&#x8FD0;&#x884C;&#x7684;webpack&#x547D;&#x4EE4;&#xFF0C;&#x4F1A;<strong>&#x4F18;&#x5148;&#x4ECE;&#x672C;&#x5730;&#x9879;&#x76EE;&#x4E2D;&#x7684;node_modules&#x91CC;&#x9762;&#x627E;</strong></p>
<h2 id="cnpm&#x7684;&#x5B89;&#x88C5;">cnpm&#x7684;&#x5B89;&#x88C5;</h2>
<p><a href="http://npm.taobao.org/" target="_blank">&#x5B98;&#x7F51;</a></p>
<pre><code>&#x547D;&#x4EE4;&#x63D0;&#x793A;&#x7B26;&#x6267;&#x884C;npm install cnpm -g --registry=https://registry.npm.taobao.org
</code></pre><p><strong>&#x6CE8;&#x610F;&#x70B9;&#xFF1A;</strong>&#x5B89;&#x88C5;&#x5B8C;&#x540E;&#x6700;&#x597D;&#x67E5;&#x770B;&#x5176;&#x7248;&#x672C;&#x53F7;cnpm -v&#x6216;&#x5173;&#x95ED;&#x547D;&#x4EE4;&#x63D0;&#x793A;&#x7B26;&#x91CD;&#x65B0;&#x6253;&#x5F00;&#xFF0C;&#x5B89;&#x88C5;&#x5B8C;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x6709;&#x53EF;&#x80FD;&#x4F1A;&#x51FA;&#x73B0;&#x9519;&#x8BEF;</p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../md/node.js/nvm.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: nvm管理nodejs"><i class="fa fa-angle-left"></i></a>
        
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"expandable-chapters-interactive":{},"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
